home *** CD-ROM | disk | FTP | other *** search
/ All for Cell Phones: Sony Ericsson / Sony-Ericsson 2004.iso / Java / Kool / Kool.jar / kool / Shoot.class (.txt) < prev   
Encoding:
Java Class File  |  2001-12-24  |  1.4 KB  |  36 lines

  1. package kool;
  2.  
  3. import com.siemens.mp.game.GraphicObject;
  4. import com.siemens.mp.game.Sprite;
  5.  
  6. public class Shoot extends Sprite {
  7.    public static final int SPIRAL = 1;
  8.    public static final int BULLET = 2;
  9.    public int type;
  10.    public static int SHOOTTIME = 15;
  11.    public static int SHOOTSPEED = 5;
  12.    private int shootCount = 0;
  13.    private static byte[] shoot1_bin = new byte[]{64, 64, -64, 64, 96, 64, -64, 64, 96, 64, -64, 64, 96, 64, -64, 64, 96, 64, -64, 64, 96, 64, -64, 64, 96, 64, -64, 64, 96, 64, -64, 64, 96, 64, -64, 64, 96, 64, -64, 64, 96, 64, -64, 64, 96, 64, -64, 64};
  14.  
  15.    public Shoot(int type) {
  16.       super(shoot1_bin, 0, 8, 48, shoot1_bin, 0, 1);
  17.       ((Sprite)this).setCollisionRectangle(0, 0, 3, 48);
  18.       this.type = type;
  19.    }
  20.  
  21.    public void fire(Player p) {
  22.       ((Sprite)this).setPosition(((Sprite)p).getXPosition() + 7, ((Sprite)p).getYPosition() - 8);
  23.       ((GraphicObject)this).setVisible(true);
  24.       this.shootCount = 0;
  25.    }
  26.  
  27.    public void move() {
  28.       ((Sprite)this).setPosition(((Sprite)this).getXPosition(), ((Sprite)this).getYPosition() - SHOOTSPEED);
  29.       ++this.shootCount;
  30.       if (this.shootCount > SHOOTTIME) {
  31.          ((GraphicObject)this).setVisible(false);
  32.       }
  33.  
  34.    }
  35. }
  36.